$(function(){
		
});
function pmoListTab(){
	$(function(){
		/*切换*/
		var index=0;
		var length=$("#pSlide .pmo-item").length;
		var itemWidth=$("#pSlide .pmo-item").outerWidth(true);
		var i=1;

		function showImg(i){
			$("#pSlide .pmo-item").eq(i).siblings();
		}

		function slideNext(){
			if(index >= 0 && index < length-4) {
				 ++index;
				 showImg(index);
			}else{
				if(confirm("It's the last one, click OK to rebrowse!")){
					showImg(0);
					index=0;
					aniPx=(length-4)*itemWidth+'px';
					$("#pSlide .pmo-list").animate({ "left": "+="+aniPx },200);
					i=1;
				}
				return false;
			}
			if(i<0 || i>length-4) {return false;}						  
			$("#pSlide .pmo-list").animate({ "left": "-="+itemWidth+"px"},200)
			i++;
		}
		 
		function slideFront(){
			if(index >= 1 ) {
				--index;
				showImg(index);
			}
			if(i<2 || i>length+4) {return false;}
			$("#pSlide .pmo-list").animate({ "left": "+="+itemWidth+"px" },200)
			i--;
		}
		$("#next_pmo").click(function(){
			slideNext();
		});
		$("#pre_pmo").click(function(){
			slideFront();
		});
	});
}
function pmoClick(){
	$(function(){
		/*Create New*/
		$("#create_pmo").click(function(){
			$("body").css({"overflow-y":"hidden"});
			$("body").append(createNewPmo());
			$(".pmo-close").on("click",function(){
				$("body").css({"overflow-y":"scroll"});
				$(".newObject-mask").remove();
			});
			$("#newPMO_Submit").on("click",function(){
				var newPmoName = $("#newPMO_pmoName").val();
				if(newPmoName == ""){
					alert("Content cannot be empty！");
				}else{
					$("body").css({"overflow-y":"scroll"});
					$(".newObject-mask").remove();
					//$("#pmo-admin").after(newPmoL(newPmoName));
					$(".pmo-list").prepend(newPmoL(newPmoName));
					pmoListTab();
					CurrentClick();
				}
			});
		});
	});
}
function CurrentClick(){
	$(function(){
		/*Current Project*/
		$(".pmo-currentPro-btn").click(function(){
			currentProject();
			$(".projectTable").empty();
		});
	});
}
function completedClick(){
	$(function(){
		/*completed Project*/
		$(".pmo-completedPro-btn").one("click",function(){
			completedProject();
		});
	});
}
function createNewPmo(){
	var html = "";
	html = html + "<div class=\"newObject-mask\">";
	html = html + "<div class=\"pmo-item\">";
	html = html + "<a class=\"pmo-close\">X</a>";
	html = html + "<h3><label>Name</label>"
	html = html + "<input id=\"newPMO_pmoName\" type=\"text\" name=\"pmoName\"/></h3>";
	html = html + "<p class=\"pmo-user\">";
	html = html + "<span class=\"pmo-userImg\"><img src=\"../img/gdoxa.jpg\" alt=\"\"/></span>";
	html = html + "<span><input name=\"owner\" type=\"checkbox\" checked=\"checked\"/><label>See All Projects</label></span>";
	html = html + "</p>";
	html = html + "<ul>";
	html = html + "<li><label>Titler</label>";
	html = html + "<p><input id=\"newPMO_pmoTitler\" type=\"text\" name=\"pmoTitler\"/></P>";
	html = html + "</li>";
	html = html + "<li><label>Company</label>";
	html = html + "<p><input id=\"newPMO_pmoCompany\" type=\"text\" name=\"pmoCompany\"/></P>";
	html = html + "</li>";
	html = html + "<li><label>Region</label>";
	html = html + "<p><input id=\"newPMO_pmoRegion\" type=\"text\" name=\"pmoRegion\"/></P>";
	html = html + "</li>";
	html = html + "<li><label>Mobile</label>";
	html = html + "<p><input id=\"newPMO_pmoMobile\" type=\"text\" name=\"pmoMobile\"/></P>";
	html = html + "</li>";
	html = html + "<li><label>Email</label>";
	html = html + "<p><input id=\"newPMO_pmoEmail\" type=\"text\" name=\"pmoEmail\"/></P>";
	html = html + "</li>";
	html = html + "<li class=\"newPMO-pmoExp\"><label>Experience:</label>";
	html = html + "<p><textarea id=\"newPMO_pmoExp\" maxlength=\"250\" name=\"projectExp\"></textarea></P>";
	html = html + "</li>";
	html = html + "<li class=\"newPMO-submit\">";
	html = html + "<input id=\"newPMO_Submit\" type=\"submit\" name=\"Submit\" value=\"Add\"/>";
	html = html + "</li>";
	html = html + "</ul>";
	html = html + "</div>";
	html = html + "</div>";
	return html;
}

function newPmoL(pmoName){
	var html = "";
	html = html + "<div class=\"pmo-item\">";
	html = html + "<a class=\"pmo-del\"></a>";
	html = html + "<h3>"+pmoName+"</h3>"
	html = html + "<p class=\"pmo-user\">";
	html = html + "<span class=\"pmo-userImg\"><img src=\"../img/gdoxa.jpg\" alt=\"用户头像\"/></span>";
	html = html + "</p>";
	html = html + "<p class=\"pmo-usermsg-group\">";
	html = html + "<span>Web FrontEnd</span>";
	html = html + "<span>东方明珠</span>";
	html = html + "</p>";
	html = html + "<p>Suzhou</p>";
	html = html + "<p class=\"pmo-usermsg-group\">";
	html = html + "<span>+86 15001830739</span>";
	html = html + "<span>chaywu@gdoxa.com</span>";
	html = html + "</p>";
	html = html + "<p class=\"pmo-usermsg-group\">";
	html = html + "<span>Experience:</span>";
	html = html + "<span class=\"pmo-useExp\">3 years in I.T. and Fitout construction.</span>";
	html = html + "</p>";
	html = html + "<a class=\"pmo-currentPro-btn\">Current Projects</a>";
	html = html + "</div>";
	return html;
}
